Committing routine and even rarely required tasks to scripts is almost always a big win because you don’t have to reinvent the approach to getting work done each time it’s needed, and you save a lot of time on issues you handle often.
Here are some tips for writing bash scripts and ensuring that they’ll be easy to use, easy to update/ and hard to misuse.
Comments
One important thing to do when you're preparing a script on Linux is to add comments – especially for commands that might be a little complex. If you don’t run a script very often, comments can help ensure that you quickly grasp everything that it’s doing. If someone else has to use your scripts, the comments can make it a lot easier for them to know what to expect. So, always add comments. Even you might appreciate them! You don’t need to comment every line, just every significant group of commands. Here's a simple example.